From 1acd0e17b654e2e40da3925ae17dc74d91379f14 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 29 Dec 2009 11:18:50 +0000 Subject: [PATCH] API: Fix breakage due to MySQL 5.1 behavior change: replace an implicit comma join with an explicit INNER JOIN and add a FORCE INDEX --- includes/api/ApiQueryAllUsers.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index e2b1891751..fa0548fe99 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -66,8 +66,9 @@ class ApiQueryAllUsers extends ApiQueryBase { if (!is_null($params['group'])) { // Filter only users that belong to a given group $this->addTables('user_groups', 'ug1'); - $this->addWhere('ug1.ug_user=u1.user_id'); - $this->addWhereFld('ug1.ug_group', $params['group']); + $ug1 = $this->getAliasedName('user_groups', 'ug1'); + $this->addJoinConds(array($ug1 => array('INNER JOIN', array('ug1.ug_user=u1.user_id', + 'ug1.ug_group' => $params['group'])))); } if ($params['witheditsonly']) @@ -103,6 +104,8 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addFieldsIf('u1.user_registration', $fld_registration); $this->addOption('ORDER BY', 'u1.user_name'); + $u1 = $this->getAliasedName('user', 'u1'); + $this->addOption('USE INDEX', array($u1 => 'user_name')); $res = $this->select(__METHOD__); -- 2.20.1